<?php

/**
 * This is the model class for table "sms_out".
 *
 * The followings are the available columns in table 'sms_out':
 * @property integer $ID_SMS
 * @property string $TYPE
 * @property string $RECIPIENT
 * @property string $TEXT
 * @property string $WAP_URL
 * @property string $WAP_EXPIRY_DATE
 * @property string $WAP_SIGNAL
 * @property string $CREATE_DATE
 * @property string $ORIGANATOR
 * @property string $ENCODING
 * @property integer $STATUS_REPORT
 * @property integer $FLASH_SMS
 * @property integer $SRC_PORT
 * @property integer $DST_PORT
 * @property string $SENT_DATE
 * @property string $REF_NO
 * @property integer $PRIORITY
 * @property string $STATUS
 * @property integer $ERRORS
 * @property string $GATEWAY_ID
 *
 * The followings are the available model relations:
 * @property Reservator[] $reservators
 */
class SmsOut extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return SmsOut the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'sms_out';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ID_SMS', 'required'),
			array('ID_SMS, STATUS_REPORT, FLASH_SMS, SRC_PORT, DST_PORT, PRIORITY, ERRORS', 'numerical', 'integerOnly'=>true),
			array('TYPE, WAP_SIGNAL, ENCODING, STATUS', 'length', 'max'=>1),
			array('RECIPIENT, ORIGANATOR', 'length', 'max'=>16),
			array('TEXT', 'length', 'max'=>1000),
			array('WAP_URL', 'length', 'max'=>100),
			array('REF_NO, GATEWAY_ID', 'length', 'max'=>64),
			array('WAP_EXPIRY_DATE, CREATE_DATE, SENT_DATE', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_SMS, TYPE, RECIPIENT, TEXT, WAP_URL, WAP_EXPIRY_DATE, WAP_SIGNAL, CREATE_DATE, ORIGANATOR, ENCODING, STATUS_REPORT, FLASH_SMS, SRC_PORT, DST_PORT, SENT_DATE, REF_NO, PRIORITY, STATUS, ERRORS, GATEWAY_ID', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'reservators' => array(self::HAS_MANY, 'Reservator', 'ID_SMS'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_SMS' => 'Id Sms',
			'TYPE' => 'Type',
			'RECIPIENT' => 'Recipient',
			'TEXT' => 'Text',
			'WAP_URL' => 'Wap Url',
			'WAP_EXPIRY_DATE' => 'Wap Expiry Date',
			'WAP_SIGNAL' => 'Wap Signal',
			'CREATE_DATE' => 'Create Date',
			'ORIGANATOR' => 'Origanator',
			'ENCODING' => 'Encoding',
			'STATUS_REPORT' => 'Status Report',
			'FLASH_SMS' => 'Flash Sms',
			'SRC_PORT' => 'Src Port',
			'DST_PORT' => 'Dst Port',
			'SENT_DATE' => 'Sent Date',
			'REF_NO' => 'Ref No',
			'PRIORITY' => 'Priority',
			'STATUS' => 'Status',
			'ERRORS' => 'Errors',
			'GATEWAY_ID' => 'Gateway',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_SMS',$this->ID_SMS);
		$criteria->compare('TYPE',$this->TYPE,true);
		$criteria->compare('RECIPIENT',$this->RECIPIENT,true);
		$criteria->compare('TEXT',$this->TEXT,true);
		$criteria->compare('WAP_URL',$this->WAP_URL,true);
		$criteria->compare('WAP_EXPIRY_DATE',$this->WAP_EXPIRY_DATE,true);
		$criteria->compare('WAP_SIGNAL',$this->WAP_SIGNAL,true);
		$criteria->compare('CREATE_DATE',$this->CREATE_DATE,true);
		$criteria->compare('ORIGANATOR',$this->ORIGANATOR,true);
		$criteria->compare('ENCODING',$this->ENCODING,true);
		$criteria->compare('STATUS_REPORT',$this->STATUS_REPORT);
		$criteria->compare('FLASH_SMS',$this->FLASH_SMS);
		$criteria->compare('SRC_PORT',$this->SRC_PORT);
		$criteria->compare('DST_PORT',$this->DST_PORT);
		$criteria->compare('SENT_DATE',$this->SENT_DATE,true);
		$criteria->compare('REF_NO',$this->REF_NO,true);
		$criteria->compare('PRIORITY',$this->PRIORITY);
		$criteria->compare('STATUS',$this->STATUS,true);
		$criteria->compare('ERRORS',$this->ERRORS);
		$criteria->compare('GATEWAY_ID',$this->GATEWAY_ID,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}